<?php
/**
 * Created by PhpStorm.
 * 订单结算
 * User: caicm
 * Date: 2017/6/30
 * Time: 14:54
 */

namespace WMApi\Model;


use Think\Model;

class WmOrderClearingModel extends Model {

    /**
     * 添加结算记录
     * Created By caicm
     * @param int $seller_id  商家id
     * @param int $store_id 店铺id
     * @param int $order_id 订单id
     * @param string $order_sn 订单编号
     * @param int $uid 订单所属用户id
     * @param int $income_money 收入金额
     * @param int $order_money 订单金额
     * @param int $shipping_service_fee 配送服务费
     * @param int $account_money 账户余额（操作后的账户余额）
     * @return mixed
     */
    public function add_order_clearing($seller_id=0, $store_id=0, $order_id=0, $order_sn='', $uid=0, $income_money=0, $order_money=0, $shipping_service_fee=0, $account_money=0){

        $data = array(
            'seller_id' => $seller_id,
            'store_id' => $store_id,
            'order_id' => $order_id,
            'order_sn' => $order_sn,
            'uid' => $uid,
            'income_money' => $income_money,
            'order_money' => $order_money,
            'shipping_service_fee' => $shipping_service_fee,
            'account_money' => $account_money,
            'add_time' => gmtime(),
        );

        return $this->data($data)->add();

    }

    /**
     * 结算记录详情
     * Created By caicm
     * @param int $seller_id 商家id
     * @param int $clearing_id 结算id
     * @return mixed
     */
    public function get_order_clearing_info($seller_id=0, $clearing_id=0){

        $where = array(
            'seller_id' => $seller_id,
            'clearing_id' => $clearing_id,
        );

        return $this->where($where)->find();

    }
}